package cn.lxh.controller.app;


import cn.dev33.satoken.annotation.SaIgnore;
import cn.lxh.pojo.app.dto.CustomerCarDto;
import cn.lxh.pojo.app.dto.WXCodeDto;
import cn.lxh.result.JSONResult;
import cn.lxh.service.ICustomerCarService;
import cn.lxh.service.ICustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * AppCustomerController控制层
 */
@Tag(name = "App客户对象",description = "App客户对象")
@RestController
@RequestMapping("/app/customer")
public class AppCustomerController {

    @Autowired
    public ICustomerService customerService;

    @Autowired
    public ICustomerCarService customerCarService;

    @Operation( summary= "客户微信注册",description = "客户微信注册")
    @Parameter(name = "微信Code",description = "微信Code",required = true)
    @PostMapping("/mp/register")
    @SaIgnore // 不做登录校验
    public JSONResult mpRegister(@RequestBody @Valid WXCodeDto wxCodeDto){
        return JSONResult.success(customerService.mpRegister(wxCodeDto));
    }

    @Operation( summary= "客户添加车辆",description = "客户添加车辆")
    @Parameter(name = "customerCarDto",description = "客户车辆信息",required = true)
    @PostMapping("/addCustomerCar")
    public JSONResult addCustomerCar(@RequestBody @Valid CustomerCarDto customerCarDto){
        return JSONResult.success(customerCarService.addCustomerCar(customerCarDto));
    }
    @Operation( summary= "获取客户车辆列表信息",description = "获取客户车辆列表信息")
    @PostMapping("/selectCustomerCar")
    @SaIgnore
    public JSONResult selectCustomerCar(){
        return JSONResult.success(customerCarService.selectCustomerCar());
    }

}
